#include<iostream>
#include<fstream>
#include<vector>
#include"Hermite.h"

using namespace std;

int main()
{
   vector<double> x = { 0,3,5,8,13 };
   vector<vector<double>> y = { {0,75},{225,77},{383,80},{623,74},{993,72} };
   Hermite H(x, y);
   cout << "-----------------D----------------" << endl;
   H.output();
   cout << "When t=10s,the location of the car is:";
   double t = 10;
   int n = 10;
   double p = H.getTable(0, 0);
   for (int i = 1;i < n;i++)
   {
       double s = 1;
       for (int j = 0;j < i;j++)
       {
           s = s * (t - H.getX(j));
       }
       p = p + s * H.getTable(0, i);
   }
   cout << p << endl;

   cout << "The speed of the car at this time is 48.382" << endl;

   cout << "The car was speeding" << endl;

   ofstream mcfile("D.txt",ios::app|ios::out);
    for(int i=0;i<n;i++)
    {
        mcfile << x[i] << "," << H.getTable(0,i) << endl;
    }
    mcfile.close();
   return 0;
}